<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <meta name="Generator" content="EditPlus®">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
  <title>Document</title>
  <script src="/lib/jquery-1.12.4.js"></script>
  <script>
	var helper = {
		color: '#112233'
	};
  </script>
 </head>
 <body id="iframe-body">
	<p>iframe-body<svg width="18" height="18" viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg">
          <title>Element / Icon - Close</title>
          <path d="M10.01 8.996l7.922-7.922c.086-.086.085-.21.008-.289l-.73-.73c-.075-.074-.208-.075-.29.007L9 7.984 1.077.062C.995-.02.863-.019.788.055l-.73.73c-.078.078-.079.203.007.29l7.922 7.92-7.922 7.922c-.086.086-.085.212-.007.29l.73.73c.075.074.207.074.29-.008l7.92-7.921 7.922 7.921c.082.082.215.082.29.008l.73-.73c.077-.078.078-.204-.008-.29l-7.921-7.921z"></path>
        </svg></p>
	
	<div id="box" style="background-color: orange;">
		<iframe style="background-color: red;" src="javascript:void(function(){document.open();document.write(&quot;<!DOCTYPE html><html xmlns='http://www.w3.org/1999/xhtml' ><head><style type='text/css'>body{font-family:sans-serif;}</style><link rel='stylesheet' type='text/css' href='http://localhost:8360/mpres/zh_CN/htmledition/comm_htmledition/style/widget/ueditor_new/themes/iframe.css'/></head><body class='view' lang='en' contenteditable='true'></body><script type='text/javascript'  id='_initialScript'>var nname='yyyyyy';window.parent.helper.window = window;setTimeout(function(){/*console.log('iframe的src内：window.nname => ', window.nname);console.log('iframe的src内：window.top.nname => ', window.top.nname);console.log('iframe的src内：window.parent.nname => ', window.parent.nname);console.log('iframe的src内：window.parent===window.top => ', window.parent===window.top);console.log('iframe的src内：window.frameElement => ', window.frameElement);*/console.log('');},1000);var _tmpScript = document.getElementById('_initialScript');_tmpScript.parentNode.removeChild(_tmpScript);</script></html>&quot;);document.close();}())" frameborder="0"></iframe>
	</div>

	<br/><br/><br/>
	<!--
	<div id="box2" style="background-color: orange;">
		<iframe style="background-color: blue;" src="javascript:void(function(){document.open();document.write(&quot;<!DOCTYPE html><html xmlns='http://www.w3.org/1999/xhtml' ><head><style type='text/css'>body{font-family:sans-serif;}</style></head><body class='view' lang='en' contenteditable='true'></body><script type='text/javascript'  id='_initialScript'>var nname='zzzzzz';setTimeout(function(){window.top.childddd = window;console.log('iframe的src内：window.nname => ', window.nname);console.log('iframe的src内：window.top.nname => ', window.top.nname);console.log('iframe的src内：window.parent.nname => ', window.parent.nname);console.log('iframe的src内：window.parent===window.top => ', window.parent===window.top);console.log('iframe的src内：window.frameElement => ', window.frameElement);console.log('iframe的src内：window.document.parentWindow => ', window.document.parentWindow);console.log('iframe的src内：window.document.defaultView => ', window.document.defaultView);console.log('iframe的src内：window.document.defaultView === window => ', window.document.defaultView === window);console.log('iframe的src内：window.frameElement => ', window.frameElement);window.document.body.focus();},2000);var _tmpScript = document.getElementById('_initialScript');_tmpScript.parentNode.removeChild(_tmpScript);</script></html>&quot;);document.close();}())" frameborder="0"></iframe>
	</div>
	-->

<script type="text/javascript">
	//var nname = 'xxxxx';
	//var box = document.getElementById('box');
	//var iframe = box.getElementsByTagName('iframe')[0];
	//console.log('外侧 iframe => ', iframe);
	//console.log(window.top === window.self); // true
	//console.log(window.top.document.body.id); // iframe
	//console.log(window.self.document.body.id); // iframe
	//console.log('');


console.log(helper);
console.log(JSON.stringify(helper));

setTimeout(function(){
	console.log(window.document.hasFocus());
	console.log(helper.window.document.hasFocus());
	console.log(helper);
	//console.log(JSON.stringify(helper));

	//$(window).on('focus', function(){
		//console.log('outer-window focus');
	//});
	//$(window).on('blur', function(){
		//console.log('outer-window blur');
	//});

	window.onfocus = function(){console.log('outer-window focus');};
	window.onblur = function(){console.log('outer-window blur');};


	//$(helper.window).on('focus', function(){
		//console.log('inner-window focus');
	//});
	//$(helper.window).on('blur', function(){
		//console.log('inner-window blur');
	//});
	helper.window.onfocus = function(){console.warn('inner-window focus');};
	helper.window.onblur = function(){console.warn('inner-window blur');};
}, 500);


setTimeout(function(){
	// helper.window.document.body.focus();// 火狐和谷歌都能获取焦点，鼠标光标在闪烁。
	// helper.window.focus();// 火狐和谷歌，通过控制台信息显示获取焦点了，但没看到光标闪烁。

	console.log(document.ownerDocument);
	console.log(document.getElementById("box").ownerDocument);
	console.log(document.getElementById("box").ownerDocument === document);
}, 3000);

</script>
</body>
</html>
